#ifndef SURPACPARSER_H_
#define SURPACPARSER_H_

#ifdef Gocad_utils_enter_scope_h
#error Please include all boost depending headers before GOCAD headers!
#endif

#include <Parsers/IParsingActions.h>

#include <GSTenums.h>
#include <exceptions/GSTRuntimeException.h>

#include <boost/shared_ptr.hpp>
#include <boost/algorithm/string.hpp>

#include <iostream>
#include <fstream>
#include <string>
#include <vector>

#include <Geometry/IGeometry.h>

#include <Parsers/SurpacStyleContainer.h>


namespace GST {
namespace Parsers {
	class SurpacParser {
        typedef const char* Iterator;
	public:
		/**
		 * Parse a DTM or a STR-File
		 * @param filename path to fiele
		 * @param type geometrytype which should be parsed
		 * @param actions object which implements IParsingActions
		 * @param workingDir the path of the working dir
		 */
		static void GST_API_EXPORT parse(std::string filename, GeometryTypes type,
						  boost::shared_ptr<IParsingActions> actions, bool parse_metadata = false, const std::string& workingDir = std::string(""),std::string styleFile=std::string(""));
		/**
		 * Parse a STR-File, used from SurpacParser
		 * @param str inputstream for the str-file
		 * @param geotype type which should be parsed
		 * @param actions the object to which content should be prased
		 * @param container The Style definitions
		 * @param parse_metadata should only be metadataparsing?
		 */
		static void parseSTR(std::istream& str, GeometryTypes geotype,
							 boost::shared_ptr<IParsingActions> actions, GST::Parsers::SurpacStyleContainer& container, bool parse_metadata = false);

		//Helper Functions
		/**
		 * Parse a DTm-File, used from SurpacParser
		 * @param dtm inputstream for the dtm-file
		 * @param geotype type which should be parsed
		 * @param actions the object to which content should be prased
		 * @param container The Style definitions
		 * @param parse_metadata should only be metadataparsing?
		 * @param workingDir searchpath for str-file
		 */
		static void parseDTM(std::istream& dtm, GeometryTypes geotype,
							 boost::shared_ptr<IParsingActions> actions, GST::Parsers::SurpacStyleContainer& container, bool parse_metadata = false, const std::string& workingDir = std::string("") );
		/**
		 * dtm inputstream for the dtm-file
		 * Parse a dtm-File, used from SurpacParser
		 *
		 * @param str inputstream for the str-file
		 * @param geotype type which should be parsed
		 * @param actions the object to which content should be prased
		 * @param container The Style definitions
		 * @param parse_metadata should only be metadataparsing?
		 */		
		static void parseDTM(std::istream& dtm,std::istream& str, GeometryTypes geotype,
							 boost::shared_ptr<IParsingActions> actions, GST::Parsers::SurpacStyleContainer& container, bool parse_metadata = false);
		static std::vector<std::string> getFileContent(std::istream& file);
		static std::string getStringFromVector(const std::vector<std::string>& lines);
		static std::istream& safeGetline(std::istream& is, std::string& t);
	};


} // namespace Parsers
} // namespace geoscis

#endif /* SURPACPARSER_H_ */
